/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view.inventory;

import java.util.Date;
import java.util.List;
import model.inventory.Dept;
import utility.com.treeTable.AbstractTreeTableModel;
import utility.com.treeTable.TreeTableModel;

/**
 *
 * @author Yusup Jauhari Shandi <in.visi>
 */
public class DeptTM extends AbstractTreeTableModel{
    static protected String[] columnNames = { "KODE", "NAMA", "INDUK","TINGKAT","ID" };
    static protected Class<?>[] columnTypes = { TreeTableModel.class, String.class, Integer.class, Integer.class,Integer.class };
    private Dept data;
    
    
    public DeptTM() {
    }

    public DeptTM(Object root) {
        super(root);
    }

    
    
    @Override
    public int getColumnCount() {
        return DeptTM.columnNames.length;
    }

    @Override
    public String getColumnName(int column) {
        return columnNames[column];
    }

    @Override
    public Class<?> getColumnClass(int column) {
        return columnTypes[column];
    }

    @Override
    public Object getValueAt(Object node, int column) {
         switch (column) {
        case 0:
            return ((DeptNode) node).getKode();
        case 1:
            return ((DeptNode) node).getNama();
        case 2:
            return ((DeptNode) node).getInduk();
        case 3:
            return ((DeptNode) node).getTinkat();
        case 4:
            return ((DeptNode) node).getId();
        default:
            break;
        }
        return null;
    }

    @Override
    public boolean isCellEditable(Object node, int column) {
        return true;
    }

    @Override
    public void setValueAt(Object aValue, Object node, int column) {
        
    }

    @Override
    public Object getChild(Object parent, int index) {
       return ((DeptNode) parent).getChildren().get(index);
    }

    @Override
    public int getChildCount(Object parent) {
        return  ((DeptNode) parent).getChildren().size();
    }

}
